<?php
/*
* This file is a template part
* produces WordPress Loop for use in index.php (posts page)
* moved to theme root from contents folder @since version 2.6
*/
 
$ka_blogtitle = get_option('ka_blogtitle');
$ka_searchbar = get_option('ka_searchbar');
$ka_crumbs = get_option('ka_crumbs');
$ka_blogbutton = get_option('ka_blogbutton');
$ka_blogauthor = get_option('ka_blogauthor');
$ka_related_posts = get_option('ka_related_posts');
$ka_related_posts_title = get_option('ka_related_posts_title');
$ka_related_posts_count = get_option('ka_related_posts_count');
$ka_posted_by = get_option('ka_posted_by');
$ka_post_date = get_option('ka_post_date');
if ($ka_post_date != "false"){ $ka_post_date_result = 'style="background:none !important;"';}else{$ka_post_date_result = '';}
$ka_dragshare = get_option('ka_dragshare');
$blog_image_frame = get_option('ka_blog_image_frame');


//@since 3.0.3, modified by denzel, we do this only if WPML is installed, 
//or exclude category will not work for other languages on posts page.
//This is a WPML issue, not sure why it does not obey pre_get_posts hook.
if(defined('ICL_LANGUAGE_CODE')):
	//check and do this only on posts page, or we will mess up archives and categories.
	global $wp_query;
	if($wp_query->is_posts_page == true):
	    //This is the page number
		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	    //get excluded category from site option.	
		$exclude = B_getExcludedCats();
		//this is 'Blog pages show at most option' in wp admin > settings > reading	
		$post_per_page = get_option('posts_per_page');
		//custom query string. 
		$query_string ="posts_per_page=$post_per_page&cat=$exclude&paged=$paged";
		query_posts($query_string);
	endif;
endif;


if (have_posts()) : while (have_posts()) : the_post(); 

    //retrieve all post meta of posts in the loop.

    $linkpost = get_post_meta($post->ID, "_jcycle_url_value", $single = true);
    $external_image_url = get_post_meta($post->ID,'truethemes_external_image_url',true);
    $video_url = get_post_meta($post->ID,'truethemes_video_url',true);
    $permalink = get_permalink($post->ID);
    //prepare to get image
    $thumb = get_post_thumbnail_id();
    $image_width = 140;
    $image_height = 140;

    //use truethemes image croping script, function moved to truethemes_framework/global/basic.php
    $image_src = truethemes_crop_image($thumb,$external_image_url,$image_width,$image_height);

?>

    <?php
        //required by theme check plugin
        //need to use post_class()  http://codex.wordpress.org/Template_Tags/post_class
        //or http://codex.wordpress.org/Function_Reference/get_post_class
        //these are special style class, use browser view source to see.
        $array_post_classes = get_post_class(); 
        $post_classes = '';
        foreach($array_post_classes as $post_class){
            $post_classes .= " ".$post_class;
        }
    ?>


    <div class="integrante_equipo">
        
        <div class="post_image">
            <?php
            $html = truethemes_generate_blog_image($image_src,$image_width,$image_height,$blog_image_frame,$linkpost,$permalink,$video_url);
            echo $html;
            ?>
        </div><!-- end post_image -->

        <div class="post_title">
            <?php truethemes_begin_post_title_hook();// action hook, see truethemes_framework/global/hooks.php ?>
            <?php if ($linkpost == ''){ ?>
                <h4><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
            <?php }else{ ?>
                <h4><a href="<?php echo $linkpost; ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
            <?php } ?>
            <?php truethemes_end_post_title_hook();// action hook, see truethemes_framework/global/hooks.php ?>
        </div><!-- end post_title -->


        <div class="post_content" style="display: none">
            the_content();
        </div><!-- end post_content -->

    </div><!-- end blog_wrap -->


<?php endwhile; else: ?>
    <h2><?php _e('Nothing Found', 'truethemes_localize') ?></h2>
    <p><?php _e('Sorry, it appears there is no content in this section.', 'truethemes_localize') ?></p>
<?php endif; ?>
    
    
<?php
    if(function_exists('wp_pagenavi')) { 
        wp_pagenavi(); 
    }else{
        //not using this function, just for theme check plugin requirement.
        //do not remove this.. 
        paginate_links(); 
    } 
?>